import os
import shutil
import pandas as pd
import numpy as np

labels = pd.read_csv(r"F:\SCIENCE_AND_MATH\Machine Learning\MCM\2021C\dataset\1、data_merged.csv", usecols=["Lab Status", "FileName"])
labels = labels.set_index(['FileName'])
# print(labels)

oldseg_path = r"F:\SCIENCE_AND_MATH\Machine Learning\MCM\2021C\dataset\2021MCM_ProblemC_Files"
Positive_path = r"F:\SCIENCE_AND_MATH\Machine Learning\MCM\2021C\dataset\data_classified\Positive"
Negative_path = r"F:\SCIENCE_AND_MATH\Machine Learning\MCM\2021C\dataset\data_classified\Negative"
Unverified_path = r"F:\SCIENCE_AND_MATH\Machine Learning\MCM\2021C\dataset\data_classified\Unverified"
Unprocessed_path = r"F:\SCIENCE_AND_MATH\Machine Learning\MCM\2021C\dataset\data_classified\Unprocessed"


for fileName in labels:
    for i in range(len(labels)):
        # print (labels[fileName].index[i])
        # print(labels[fileName].values[i] == "Positive ID")
        if labels[fileName].values[i] == "Positive ID":
            segname = labels[fileName].index[i]
            old_segname = os.path.join(oldseg_path,segname)
            newseg_name = os.path.join(Positive_path,segname)
            shutil.copyfile(old_segname, newseg_name)

        elif labels[fileName].values[i] == "Negative ID":
            segname = labels[fileName].index[i]
            old_segname = os.path.join(oldseg_path,segname)
            newseg_name = os.path.join(Negative_path,segname)
            shutil.copyfile(old_segname, newseg_name)

        elif labels[fileName].values[i] == "Unverified":
            segname = labels[fileName].index[i]
            old_segname = os.path.join(oldseg_path,segname)
            newseg_name = os.path.join(Unverified_path,segname)
            shutil.copyfile(old_segname, newseg_name)

        elif labels[fileName].values[i] == "Unprocessed":
            segname = labels[fileName].index[i]
            old_segname = os.path.join(oldseg_path,segname)
            newseg_name = os.path.join(Unprocessed_path,segname)
            shutil.copyfile(old_segname, newseg_name)
